
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/newQuotation.do"/>

<%
    String chipTracContext = "/" + ConfigManager.getChipTracContext();
    int i=0;
    int index = 0;
    String selectedMethod = null;
    String selectedAccount = null;
%>

<%@page import="com.scalar.chiptrack.commons.Constants,com.scalar.chiptrack.commons.SessionKeys,
                  com.scalar.chiptrack.sales.ContactPerson,
                  com.scalar.chiptrack.sales.CustomerPartNumber,
                  com.scalar.chiptrack.sales.LineItem,
                  com.scalar.chiptrack.sales.Quotation,
                  com.scalar.chiptrack.sales.forms.quote.QuotationForm,
                  com.scalar.chiptrack.users.Functionality,
                  com.scalar.chiptrack.users.User,
                  com.scalar.chiptrack.utils.ConfigManager,
                  java.util.ArrayList,
				  java.util.HashMap" %>

 <%
            java.util.ArrayList optionlist = null;
            java.util.ArrayList mfgList = null;
            org.apache.struts.util.LabelValueBean option = null;
            CustomerPartNumber customerPartNo = new  CustomerPartNumber();
            StringBuffer strBuffer = null;
            StringBuffer strBuffer1 = null;
            int mfgListsize =0;
            HashMap  quotationMap = ( HashMap ) session.getAttribute( "quotationMap" );
            Quotation quotationFromMap = null;
            if ( quotationMap != null )
            {
                com.scalar.chiptrack.sales.forms.quote.QuotationForm quotationForm1 = (QuotationForm)request.getAttribute("QuotationForm");
                quotationFromMap = ( Quotation ) quotationMap.get( quotationForm1.getCustomerId()+"" );
                if( quotationFromMap != null )
                {
                    mfgList = quotationFromMap.getMfgParts();;
                }
            }
        %>
<logic:iterate id="myHashMap" name="lineItemsWithSubtotals">
    <logic:iterate id="lineItemList" name="myHashMap" >
          <logic:iterate id="LineItem" name="lineItemList" property="key" type="com.scalar.chiptrack.sales.LineItem">
<%-- Till here Prabhanjan --%>


      <%-- <logic:iterate id="LineItem" name="lineItems" type="com.scalar.chiptrack.sales.LineItem"> --%>

      <tr>


       <td width="8%" bgcolor="#DEE1E2" align=center>
            <logic:equal name="LineItem" property="isClose" value="true">
                <logic:equal name="LineItem" property="isApproved" value="true">
                    <logic:greaterThan name="LineItem" property="quantity" value="0">
                        <input type="checkbox" name="isClose<bean:write name="LineItem" property="lineItemNo"/>" value="on" CHECKED>
                     </logic:greaterThan>
                     <logic:lessEqual name="LineItem" property="quantity" value="0">
                        <input type="checkbox" name="isClose<bean:write name="LineItem" property="lineItemNo"/>" value="on" disabled="true">
                     </logic:lessEqual>
                </logic:equal>
                <logic:notEqual name="LineItem" property="isApproved" value="true">
                    <input type="checkbox" name="isClose<bean:write name="LineItem" property="lineItemNo"/>" value="on" disabled="true">
                </logic:notEqual>
            </logic:equal>

            <logic:equal name="LineItem" property="isClose" value="false">
                <logic:equal name="LineItem" property="isApproved" value="true">
                    <logic:greaterThan name="LineItem" property="quantity" value="0">
                        <input type="checkbox" name="isClose<bean:write name="LineItem" property="lineItemNo"/>" value="on" >
                     </logic:greaterThan>
                     <logic:lessEqual name="LineItem" property="quantity" value="0">
                        <input type="checkbox" name="isClose<bean:write name="LineItem" property="lineItemNo"/>" value="on" disabled="true">
                     </logic:lessEqual>
                </logic:equal>
                <logic:notEqual name="LineItem" property="isApproved" value="true">
                    <input type="checkbox" name="isClose<bean:write name="LineItem" property="lineItemNo"/>" value="on" disabled="true">
                </logic:notEqual>
            </logic:equal>
       </td>

       <td width="8%" bgcolor="#DEE1E2" align=center>

            <logic:equal name="LineItem" property="isTransfer" value="true">
                <logic:equal name="LineItem" property="isApproved" value="true">
                    <logic:greaterThan name="LineItem" property="quantity" value="0">
                        <input type="checkbox" name="isTransfer<bean:write name="LineItem" property="lineItemNo"/>" value="on" CHECKED>
                    </logic:greaterThan>
                    <logic:lessEqual name="LineItem" property="quantity" value="0">
                        <input type="checkbox" name="isTransfer<bean:write name="LineItem" property="lineItemNo"/>" value="on" CHECKED disabled="true">
                    </logic:lessEqual>
                </logic:equal>
                <logic:notEqual name="LineItem" property="isApproved" value="true">
                    <input type="checkbox" name="isTransfer<bean:write name="LineItem" property="lineItemNo"/>" value="on" CHECKED disabled="true">
                </logic:notEqual>
            </logic:equal>

            <logic:equal name="LineItem" property="isTransfer" value="false">
                <logic:equal name="LineItem" property="isApproved" value="true">
                    <logic:greaterThan name="LineItem" property="quantity" value="0">
                        <input type="checkbox" name="isTransfer<bean:write name="LineItem" property="lineItemNo"/>" value="on">
                    </logic:greaterThan>
                    <logic:lessEqual name="LineItem" property="quantity" value="0">
                        <input type="checkbox" name="isTransfer<bean:write name="LineItem" property="lineItemNo"/>" value="on" CHECKED disabled="true">
                    </logic:lessEqual>
                </logic:equal>
                <logic:notEqual name="LineItem" property="isApproved" value="true">
                    <input type="checkbox" name="isTransfer<bean:write name="LineItem" property="lineItemNo"/>" value="on" disabled="true">
                </logic:notEqual>
            </logic:equal>

        <%--<html:hidden name="LineItem" property="isApproved" /> --%>
        <input type="hidden" name="isApproved" value="<%=LineItem.getIsApproved()%>">



       </td>

	   <td width="8%" bgcolor="#DEE1E2">
                <html:text name="LineItem" property="lineItemNo" size='6' styleClass="txfield" disabled="true"/>
                <%-- <html:hidden name="LineItem" property="lineItemId" /> --%>
                <input type="hidden" name="lineItemId" value="<%=LineItem.getLineItemId()%>">
				<%-- Commented by veeru on 26/02/04
                  <html:hidden name="LineItem" property="lineItemNo" />  --%>
                <input type="hidden" name="jsLineItemNo" value="<%=LineItem.getLineItemNo()%>">
       </td>


      <td width="8%" bgcolor="#DEE1E2">
                <html:text name="LineItem" property="poLineItemNo" size='6' styleClass="txfield" disabled="true"/>
                <%-- <html:hidden name="LineItem" property="poLineItemNo" /> --%>
                <input type="hidden" name="poLineItemNo" value="<%=LineItem.getPoLineItemNo()%>">
           </td>


	   <td width="18%" bgcolor="#DEE1E2">



                <select name="manufacturingPartNo" class="txfield"  disabled="true">
                <option value="" ></option>

                <%
                    /* strBuffer = new StringBuffer();
                     for(int cnt=0;cnt<optionlist.size();cnt++)
                     {
                         option = (org.apache.struts.util.LabelValueBean)optionlist.get(cnt);
                         if( (option.getValue()).equalsIgnoreCase(LineItem.getManufacturingPartNo()) ) {
                             strBuffer.append("<option value='").append(option.getValue()).append("' selected>");
                         } else {
                             strBuffer.append("<option value='").append(option.getValue()).append("'>");
                         }

                         strBuffer.append(option.getLabel()).append("</option>\n");
                      }
                      out.println(strBuffer);
                      */
                       //Added by sarada on 25th Feb  2004
                         strBuffer1 = new StringBuffer();
                         for(int k=0;k<mfgList.size();k++)
                         {
                               customerPartNo = (CustomerPartNumber)mfgList.get(k);

                           if( (customerPartNo.getManufacturingPartNo().trim()).equalsIgnoreCase(LineItem.getManufacturingPartNo().trim()) )
                                 {
                                     strBuffer1.append("<option value='").append(customerPartNo.getManufacturingPartNo()).append("'selected>");
                                 }
                                 else
                                 {
                                     strBuffer1.append("<option value='").append(customerPartNo.getManufacturingPartNo()).append("'>");
                                 }
                               strBuffer1.append(customerPartNo.getManufacturingPartNo()).append("</option>\n");
                         }

                          out.println(strBuffer1);
                %>
                </select>

           </td>
		    <td width="15%" bgcolor="#DEE1E2">

            <select name="customerPartNo"  class="txfield" onchange="showHideNewCustPartNo(<%=index%>)">
                  <option value="">Select Customer Part No</option>
             <%
                       ArrayList customerPartNumbersList = (ArrayList)request.getAttribute( "customerPartNumbers"+LineItem.getLineItemNo());
                       if ( customerPartNumbersList != null )
                       {
                           StringBuffer strBuffer2 = new StringBuffer();
                           if ( !"".equalsIgnoreCase(LineItem.getCustomerPartNo()) && !customerPartNumbersList.contains(LineItem.getCustomerPartNo()) )
                           {
                                strBuffer2.append("<option value='").append(LineItem.getCustomerPartNo()).append("'selected>").append(LineItem.getCustomerPartNo()).append("</option>\n");
                           }
                           for ( int j = 0; j < customerPartNumbersList.size(); j++) {
                               String customerPartNumber =  (String)customerPartNumbersList.get(j);
                               if( (customerPartNumber).equalsIgnoreCase(LineItem .getCustomerPartNo()) )
                               {
                                   strBuffer2.append("<option value='").append(customerPartNumber).append("'selected>");
                               }
                               else
                               {
                                   strBuffer2.append("<option value='").append(customerPartNumber).append("'>");
                               }
                               strBuffer2.append(customerPartNumber).append("</option>\n");
                           }
                           out.println(strBuffer2);
                       }
           %>
                <option value="-2" <%="-2".equals(LineItem .getCustomerPartNo()) ? "selected" : ""%> >--Add New CustomerPart No--</option>
                <html:text name="LineItem" property="newCustomerPartNo" style="display:none;" styleClass="txfield" maxlength="50" size="20"/>
           </select>


			</td>
           <td width="18%" bgcolor="#DEE1E2">
           <input type="hidden" name="">
		   <font class="NArialL">
                <logic:greaterThan name="LineItem" property="quantity" value="0">
                    <logic:equal name="LineItem" property="isApproved" value="true">
                        <html:textarea name="LineItem" property="lineItemDescription"  styleClass="txfield" onkeydown="javascript:setTextAreaMaxLength(this,200)" onkeyup="javascript:setTextAreaMaxLength(this,200)" />
                    </logic:equal>
                    <logic:equal name="LineItem" property="isApproved" value="false">
                        <html:textarea name="LineItem" property="lineItemDescription"  styleClass="txfield" disabled="true"/>
                    </logic:equal>
                </logic:greaterThan>

                <logic:lessEqual name="LineItem" property="quantity" value="0">
                   <html:textarea name="LineItem" property="lineItemDescription"  styleClass="txfield" disabled="true"/>
                </logic:lessEqual>


           </font>
           </td>
			<td width="5%" bgcolor="#DEE1E2" align=center>
               <logic:equal name="LineItem" property="isTaxable" value="true">
                <logic:greaterThan name="LineItem" property="quantity" value="0">
                  <logic:equal name="LineItem" property="isApproved" value="true">
                    <input type="checkbox" name=isTaxable<bean:write name="LineItem" property="lineItemNo"/> value="on" CHECKED>
                  </logic:equal>
                  <logic:equal name="LineItem" property="isApproved" value="false">
                    <input type="checkbox" name=isTaxable<bean:write name="LineItem" property="lineItemNo"/> value="on" CHECKED disabled="true">
                  </logic:equal>
                </logic:greaterThan>
                <logic:lessEqual name="LineItem" property="quantity" value="0">
                   <input type="checkbox" name=isTaxable<bean:write name="LineItem" property="lineItemNo"/> value="on" CHECKED disabled="true">
                </logic:lessEqual>
               </logic:equal>


               <logic:equal name="LineItem" property="isTaxable" value="false">
               <logic:greaterThan name="LineItem" property="quantity" value="0">
                  <logic:equal name="LineItem" property="isApproved" value="true">
                    <input type="checkbox" name=isTaxable<bean:write name="LineItem" property="lineItemNo"/> value="on">
                  </logic:equal>
                  <logic:equal name="LineItem" property="isApproved" value="false">
                    <input type="checkbox" name=isTaxable<bean:write name="LineItem" property="lineItemNo"/> value="on" disabled="true">
                  </logic:equal>
                </logic:greaterThan>
                <logic:lessEqual name="LineItem" property="quantity" value="0">
                   <input type="checkbox" name=isTaxable<bean:write name="LineItem" property="lineItemNo"/> value="on"disabled="true">
                </logic:lessEqual>
               </logic:equal>


           </td>
           <%if(Constants.CLIENT_NAME_AIRGO.equalsIgnoreCase(ConfigManager.getClientNameAirgo() )){ %>
           <td width="14%" bgcolor="#DEE1E2" nowrap>
                   <html:text name="LineItem" property="quotedDate" size='15' styleClass="txfield" disabled="true"/>
                   <img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20>
           </td>
           <td width="5%" bgcolor="#DEE1E2">
                   <html:text name="LineItem" property="quotedQuantity"  size='8' styleClass="valuetxfield" disabled="true" />
           </td>
           <%}%>
           <td width="14%" bgcolor="#DEE1E2" nowrap>
                <logic:greaterThan name="LineItem" property="quantity" value="0">
                  <logic:equal name="LineItem" property="isApproved" value="true">
                    <html:text name="LineItem" property="requestDate" size='15' styleClass="txfield"/>
                   <!-- Added by veeru on (26th March 2004)  -->
                   <a href="javascript:if(document.QuotationForm.requestDate.length!=null){openCalendar(document.QuotationForm.requestDate[<%=index%>])}else{openCalendar(document.QuotationForm.requestDate)}"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
                  </logic:equal>
                  <logic:equal name="LineItem" property="isApproved" value="false">
                    <html:text name="LineItem" property="requestDate" size='15' styleClass="txfield" disabled="true"/>
                   <img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20>
                  </logic:equal>
                </logic:greaterThan>
                <logic:lessEqual name="LineItem" property="quantity" value="0">
                   <html:text name="LineItem" property="requestDate" size='15' styleClass="txfield" disabled="true"/>
                   <img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20>
                </logic:lessEqual>
           </td>
          <%--<td width="14%" bgcolor="#DEE1E2" nowrap>
                <logic:greaterThan name="LineItem" property="quantity" value="0" >
                  <logic:equal name="LineItem" property="isApproved" value="true">
                    <html:select  name="LineItem" property="leadTime"  styleClass="txfield" >
                        <html:option value="0">Select Lead Time</html:option>
                        <html:optionsCollection value="value" name="LineItem" property="leadTimeList" label="label"/>
                    </html:select>
                  </logic:equal>
                  <logic:equal name="LineItem" property="isApproved" value="false">
                      <html:select  name="LineItem" property="leadTime"  styleClass="txfield" disabled="true">
                        <html:option value="0">Select Lead Time</html:option>
                        <html:optionsCollection value="value" name="LineItem" property="leadTimeList" label="label"/>
                    </html:select>
                  </logic:equal>
                </logic:greaterThan>
                <logic:lessEqual name="LineItem" property="quantity" value="0">
                   <html:select  name="LineItem" property="leadTime"  styleClass="txfield" disabled="true" >
                        <html:option value="0">Select Lead Time</html:option>
                        <html:optionsCollection value="value" name="LineItem" property="leadTimeList" label="label"/>
                    </html:select>
                </logic:lessEqual>
           </td> --%>
           <td width="5%" bgcolor="#DEE1E2">
                <logic:greaterThan name="LineItem" property="quantity" value="0">
                   <logic:equal name="LineItem" property="isApproved" value="true">
                        <html:text name="LineItem" property="quantity"  size='8' styleClass="valuetxfield" onchange="javascript:isValidInteger(this);" />
                   </logic:equal>
                   <logic:equal name="LineItem" property="isApproved" value="false">
                        <html:text name="LineItem" property="quantity"  size='8' styleClass="valuetxfield" disabled="true" />
                   </logic:equal>
                </logic:greaterThan>
                <logic:lessEqual name="LineItem" property="quantity" value="0">
                   <html:text name="LineItem" property="quantity"  size='8' styleClass="valuetxfield" disabled="true" />
                </logic:lessEqual>


                <input type="hidden" name="oldQty" value="<%=LineItem.getQuantity()%>">
                <%-- <html:hidden name="LineItem" property="previousQuantity" /> --%>
                <input type="hidden" name="previousQuantity" value="<%=LineItem.getPreviousQuantity()%>">

        </td>
	   <td width="10%" bgcolor="#DEE1E2">
                <html:text name="LineItem" property="unitPriceAsDouble" size='12' styleClass="valuetxfield" disabled="true"/></td>
           <td width="15%" bgcolor="#DEE1E2">
                <html:text name="LineItem" property="amountAsString" size='25' styleClass="valuetxfield" disabled="true"/></td>

			<!-- commented by Sarada on 26th Feb 2004 as we are not using ZeroPrice -->
             <%-- <td bgcolor="#DEE1E2" align="center">
                <logic:equal name="LineItem" property="zeroPrice" value="true">
                 <input type="checkbox" name=zeroPrice<bean:write name="LineItem" property="lineItemNo"/> value="on" CHECKED></td>
                 </logic:equal>
                 <logic:equal name="LineItem" property="zeroPrice" value="false">
                 <input type="checkbox" name=zeroPrice<bean:write name="LineItem" property="lineItemNo"/> value="on" ></td>
                 </logic:equal>
             --%>
     </tr>
     <%index++;%>
     </logic:iterate>

<%-- Added by Prabhanjan on 07 Mar 2004 --%>
        <tr>
             <bean:define id="subTotal" name="lineItemList" property="value" type="com.scalar.chiptrack.sales.SubTotal"/>
             <%if(Constants.CLIENT_NAME_AIRGO.equalsIgnoreCase(ConfigManager.getClientNameAirgo() )){ %>
             <td colspan="10" width="15%" bgcolor="#FFFFFF" class="NArialL" align="right">
                Sub Total
            </td>
            <td colspan="1" width="15%" bgcolor="#FFFFFF" class="NArialL" align="right">
            <bean:write name="subTotal" property="subTotalProposedQty" />
            </td>
            <td colspan="1" width="15%" bgcolor="#FFFFFF" class="NArialL" align="right">
            </td>
            <%}else{%>
             <td colspan="8" width="15%" bgcolor="#FFFFFF" class="NArialL" align="right">
                Sub Total
            </td>
            <%}%>
           <%-- <td colspan="9" width="15%" bgcolor="#FFFFFF" class="NArialL" align="right">
                Sub Total
            </td>--%>

            <%-- Modified by Prabhanjan (3 Arp 2004) --%>
            <%--<bean:define id="subTotal" name="lineItemList" property="value" type="com.scalar.chiptrack.sales.SubTotal"/>--%>
            <td colspan="1" width="15%" bgcolor="#FFFFFF" class="NArialL" align="right">
                <bean:write name="subTotal" property="subTotalQty" />
            </td>
            <td>&nbsp;</td>
            <td colspan="1" width="15%" bgcolor="#FFFFFF" class="NArialL" align="right">
                <bean:write name="subTotal" property="subTotalAmt" />
            </td>
        </tr>
   </logic:iterate>
</logic:iterate>
<%-- Till here Prabhanjan on 07 Mar 2004 --%>
